﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using SDT.Mobile.Models;
using SDT.Model;

namespace SDT.Mobile.Controllers
{
    [HandleError]
    public class HomeController : Controller
    {
        SDTDataContext data = new SDTDataContext();
        public ActionResult Detail()
        {
            HomeViewModels h = new HomeViewModels();
            h.ProductTypes = data.ProductTypes.ToList();
            h.ProductCategories = data.ProductCategories
                                        .Where(e => e.ActiveYN == true)
                                        .ToList();
            h.Products = data.Products
                                .Where(e => e.PubYN == true)
                                .ToList();
            h.ArticleCategories = data.ArticleCategories
                                    .Where(e => e.ParentID != null)
                                    .ToList();    
            h.Articles = data.Articles.ToList();
            return View(h);
        }
        public ActionResult Index()
        {
            HomeViewModels h = new HomeViewModels();
            h.ArticleCategories = data.ArticleCategories
                .Where(e => e.ActiveYN == true)
                .Where(e => e.ID != ConfigManager.GetArticle())
                .Where(e => e.ParentID == null)
                .OrderBy(e => e.Priority).ToList();
            return View(h);
        }
        public ActionResult About()
        {
            return View();
        }
    }
}
